'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER } = Sequelize;
    
    // 在products表中添加brand_id字段
    await queryInterface.addColumn('products', 'brand_id', {
      type: INTEGER,
      allowNull: true,
      comment: '品牌ID'
    });
    
    // 添加索引
    await queryInterface.addIndex('products', ['brand_id'], {
      name: 'products_idx_brand_id',
      unique: false
    });
  },

  down: async (queryInterface, Sequelize) => {
    // 删除索引
    await queryInterface.removeIndex('products', 'products_idx_brand_id');
    
    // 删除brand_id字段
    await queryInterface.removeColumn('products', 'brand_id');
  }
};